module lang.d.tokens.tokentype;

enum TokenType: ubyte {
    INVALID,
    EOF,

    WHITESPACE,

    COMMENT,
    DOC_COMMENT,

    IDENTIFIER,

    STRING_LITERAL,
    WSTRING_LITERAL,
    DSTRING_LITERAL,

    CHARACTER_LITERAL,

    INT_LITERAL,
    UINT_LITERAL,
    LONG_LITERAL,
    ULONG_LITERAL,

    FLOAT_LITERAL,
    DOUBLE_LITERAL,
    REAL_LITERAL,

    IFLOAT_LITERAL,
    IDOUBLE_LITERAL,
    IREAL_LITERAL,

    // Keywords
    ABSTRACT,
    ALIAS,
    ALIGN,
    ASM,
    ASSERT,
    AUTO,

    BODY,
    BOOL,
    BREAK,
    BYTE,

    CASE,
    CAST,
    CATCH,
    CDOUBLE,
    CENT,
    CFLOAT,
    CHAR,
    CLASS,
    CONST,
    CONTINUE,
    CREAL,

    DCHAR,
    DEBUG,
    DEFAULT,
    DELEGATE,
    DELETE,
    DEPRECATED,
    DO,
    DOUBLE,

    ELSE,
    ENUM,
    EXPORT,
    EXTERN,

    FALSE,
    FINAL,
    FINALLY,
    FLOAT,
    FOR,
    FOREACH,
    FOREACH_REVERSE,
    FUNCTION,

    GOTO,

    IDOUBLE,
    IF,
    IFLOAT,
    IMMUTABLE,
    IMPORT,
    IN,
    INT,
    INTERFACE,
    INVARIANT,
    IREAL,
    IS,

    LAZY,
    LONG,

    MACRO,
    MIXIN,
    MODULE,

    NEW,
    NOTHROW,
    NULL,

    OUT,
    OVERRIDE,

    PACKAGE,
    PRAGMA,
    PRIVATE,
    PROTECTED,
    PUBLIC,
    PURE,

    REAL,
    REF,
    RETURN,

    SCOPE,
    SHARED,
    SHORT,
    STATIC,
    STRUCT,
    SUPER,
    SWITCH,
    SYNCHRONIZED,

    TEMPLATE,
    THIS,
    THROW,
    TRUE,
    TRY,
    TYPEDEF,
    TYPEID,
    TYPEOF,

    UBYTE,
    UCENT,
    UINT,
    ULONG,
    UNION,
    UNITTEST,
    USHORT,

    VERSION,
    VOID,

    WCHAR,
    WHILE,
    WITH,

    PROPERTY,

    FILE,
    LINE,
    GSHARED,
    THREAD,
    TRAITS,

    DIV,  // /
    DIVASS,  // /=
    DOT,  // .
    DOTDOT,  // ..
    DOTDOTDOT,  // ...

    AND,  // &
    ANDASS,  // &=
    ANDAND,  // &&
    OR,  // |
    ORASS,  // |=
    OROR,  // ||

    MINUS,   // -
    MINUSASS,  // -=
    DECREMENT,  // --
    PLUS,  // +
    PLUSASS,  // +=
    INCREMENT,  // ++

    LESS,  // <
    LESSEQ,  // <=
    SHL,  // <<
    SHLASS,  // <<=
    LESSGREAT,  // <>
    LESSGREATEQ,  // <>=
    GREAT,  // >
    GREATEQ,  // >=
    SHR,  // >>
    SHRASS,  // >>=
    SHRUNS,  // >>>
    SHRUNSASS,  // >>>=

    NOT,  // !
    NOTEQ,  // !=
    NOTLESSGREAT,  // !<>
    NOTLESSGREATEQ,  // !<>=
    NOTLESS,  // !<
    NOTLESSEQ,  // !<=
    NOTGREAT,  // !>
    NOTGREATEQ,  // !>=
    NOTIS,  // !is

    OPEN_PAREN, // )
    CLOSE_PAREN,  // )
    OPEN_BRACKET,  // [
    CLOSE_BRACKET,  // ]
    OPEN_CURLY,  // {
    CLOSE_CURLY,  // }

    QUESTION,  // ?
    COMMA,  // ,
    SEMICOLON,  // ;
    COLON,  // :
    DOLLAR,  // $

    ASSIGN,  // =
    EQ,  // ==
    STAR,  // *
    MULTASS,  // *=
    MOD,  // %
    MODASS,  // %=
    CARET,  // ^
    CARETASS,  // ^=
    CARETCARET,  // ^^
    CARETCARETASS,  // ^^=
    TILDE,  // ~
    TILDEASS  // ~=
}

version (unittest) {
    public string getStringByTokenType(TokenType type) pure {
        with (TokenType) {
            switch (type) {
            case DIV:
                return "/";
            case DIVASS:
                return "/=";
            case AND:
                return "&";
            case ANDASS:
                return "&=";
            case ANDAND:
                return "&&";
            case OR:
                return "|";
            case ORASS:
                return "|=";
            case OROR:
                return "||";
            case MINUS:
                return "-";
            case MINUSASS:
                return "-=";
            case DECREMENT:
                return "--";
            case PLUS:
                return "+";
            case PLUSASS:
                return "+=";
            case INCREMENT:
                return "++";
            case LESS:
                return "<";
            case LESSEQ:
                return "<=";
            case SHL:
                return "<<";
            case SHLASS:
                return "<<=";
            case GREAT:
                return ">";
            case GREATEQ:
                return ">=";
            case SHR:
                return ">>";
            case SHRASS:
                return ">>=";
            case SHRUNS:
                return ">>>";
            case SHRUNSASS:
                return ">>>=";
            case NOT:
                return "!";
            case NOTEQ:
                return "!=";
            case NOTLESSGREAT:
                return "!<>";
            case NOTLESSGREATEQ:
                return "!<>=";
            case NOTLESS:
                return "!<";
            case NOTLESSEQ:
                return "!<=";
            case NOTGREAT:
                return "!>";
            case NOTGREATEQ:
                return "!>=";
            case IS:
                return "is";
            case NOTIS:
                return "!is";
            case ASSIGN:
                return "=";
            case EQ:
                return "==";
            case STAR:
                return "*";
            case MULTASS:
                return "*=";
            case MOD:
                return "%";
            case MODASS:
                return "%=";
            case CARET:
                return "^";
            case CARETASS:
                return "^=";
            case CARETCARET:
                return "^^";
            case CARETCARETASS:
                return "^^=";
            case TILDE:
                return "~";
            case TILDEASS:
                return "~=";
            case WHITESPACE:
                return "\' \'";
            default:
                return "";
            }
        }
    }
}
